<?php
namespace jy_pingdd_yafee;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	/*
		团UP
	*/
	public function teamup(){
		$pluginset=$this->plugin_setting('basic');
		$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>0);
		$team = pdo_getall('jy_weishop_groups_team',$params,array('id','goodsid','createtime'));
		if($team){
			foreach($team as $a){
				$goods=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$a['goodsid']));
				$goods=$this->model('model')->up_price($goods,$pluginset,true);
				if(time()>$goods['grouptime']*60*60+$a['createtime']){
					if($pluginset['zd_team']){
						$this->model('model')->order_success($a['id']);
					}else{
						$this->model('model')->order_cancel($a['id']);
					}
				}				
			}
		}
		if($pluginset['fan_rate']){
			//返现
			$params['status']=2;
			$dings = pdo_getall('jy_weishop_order_ding',$params);
			if($dings){
				foreach($dings as $dv){
					$order=pdo_get('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'id'=>$dv['orderid']));
					$order['goodsid']=$dv['goodsid'];
					if($order['ispay'] && $order['status']<=3){
						$this->model('model')->order_fanxian($order,$pluginset);
					}
				}
			}
		}
	}
}